/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package biz;

import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author ASUS
 */
@ManagedBean
@SessionScoped
public class ProductBean {

    List<product> items;
    List<product> listProduct;
    private String id, name;
    private float total;
    private int quantity;

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    /** Creates a new instance of productBean */
    public ProductBean() {
        items = new ArrayList<product>();
        mockdb db = new mockdb();
        listProduct = new ArrayList<product>();
        listProduct = db.productdb();


        //items.add(new product("7", "nokia", 800));
    }

    public String addToCart(String pId) {
        //items.add(new product("7", "nokia", 800));
        for (product p : listProduct) {
            if (pId == p.getId()) {
                items.add(p);
                break;
            }
        }

        return "products";
    }

    public String viewCart() {

        return "viewCart";
    }

    public String cartMore() {

        return "products";
    }

    public String update() {
        return "update";
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public List<product> getItems() {
        return items;
    }

    public void setItems(List<product> items) {
        this.items = items;
    }

    public List<product> getListProduct() {
        return listProduct;
    }

    public void setListProduct(List<product> listProduct) {
        this.listProduct = listProduct;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public float getTotal() {
        return total;
    }

    public void setTotal(float total) {
        this.total = total;
    }
}
